﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//importamos
using EventSys.BussinesEntities;

namespace EventSys.Repository
{
    public class CarrerasRepository:MasterRepository,ICarrerasRepository
    {
        public void RegistrarCarrera(Carrera carrera)
        {
            Context.Carreras.Add(carrera);
            Context.SaveChanges();
        }

        public Carrera CarreraById(int id)
        {
            var carrera = Context.Carreras.Find(id);
            return carrera;
        }

        public void EditarCarrera(Carrera carrera)
        {
            Context.Entry(carrera).State = System.Data.EntityState.Modified;
            Context.SaveChanges();
        }

        public void EliminarCarrera(int id)
        {
            throw new NotImplementedException();
        }

        public List<Carrera> GetFromAllCarrera()
        {
            var query = Context.Carreras.ToList();
            return query;
        }

        public List<Carrera> GetFromAllCarreraByCriterio(string criterio)
        {
            var query = Context.Carreras.ToList();

            if (criterio != null) {
                query = (query.Where(a => a.Carrera1.ToUpper().Contains(criterio.ToUpper()))).ToList();
            }

            return query;
        }
    }
}
